#ifndef TABLEWIDGETSDELEGATE_H
#define TABLEWIDGETSDELEGATE_H

#include <QStyledItemDelegate>



class twSerialDelegate: public QStyledItemDelegate
{
public:
    enum ESerialType {serialname,serialbaud,serialparity,serialdata,serialstop};

public:
    twSerialDelegate(ESerialType itemtype,QObject *parent=0);
    twSerialDelegate(ESerialType itemtype,QStringList ports,QObject *parent=0);

    // QAbstractItemDelegate interface
public:
    void paint(QPainter *painter, const QStyleOptionViewItem &option, const QModelIndex &index) const;
    QWidget *createEditor(QWidget *parent, const QStyleOptionViewItem &option, const QModelIndex &index) const;
    void setEditorData(QWidget *editor, const QModelIndex &index) const;
    void setModelData(QWidget *editor, QAbstractItemModel *model, const QModelIndex &index) const;

private:
    ESerialType itemType;
    QStringList serials;

};


class twNumberDelegate: public QStyledItemDelegate
{
public:
    twNumberDelegate(QObject *parent=0);

    // QAbstractItemDelegate interface
public:
    void paint(QPainter *painter, const QStyleOptionViewItem &option, const QModelIndex &index) const;
    QWidget *createEditor(QWidget *parent, const QStyleOptionViewItem &option, const QModelIndex &index) const;
    void setEditorData(QWidget *editor, const QModelIndex &index) const;
    void setModelData(QWidget *editor, QAbstractItemModel *model, const QModelIndex &index) const;


};


#endif // TABLEWIDGETSDELEGATE_H
